<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<s:url value="/css/common.less"/>" type="text/less"
	rel="stylesheet" />
	<link href="<s:url value="/css/common.css"/>" type="text/css"
	rel="stylesheet" />

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.validate.js" />"></script>
<style type="text/css">

.error {
	color: red;
}

</style>
<script type="text/javascript">
var validator ;
function insVali () {
	validator.resetForm();
}
$(document).ready(function() {
	//检查是什么状态，更新或新增
	var flag="${flag}";
	if(flag=="update"){
		$("#orgForm").attr("action","<%=basePath%>/orgmain/updateOrg.ct");
	}
	
	validator = $("#orgForm").validate({
		debug:true,
		submitHandler : function(form) {
			$("#btnAdd").attr("disabled",true);
				form.submit();
		},
		success : function (label) {
		},
		rules : {
			"orgmain.status" : {required : true},
			"orgmain.areaId" : {required : true},
			"orgmain.orgName" : {required : true}
			},
		messages : {
			"orgmain.orgName" : {required : "*请输入区域名称"},
			"orgmain.areaId" : {required : "*必选"},
			"orgmain.status" : {required : "*必选"}
		},errorPlacement: function(error, element) {
		    if ( element.is(":radio") ) 
		        error.appendTo ( element.parent() ); 
		    else if ( element.is(":checkbox") ) 
		        error.appendTo ( element.parent() ); 
		    else if ( element.is("input") ) {
		    	error.appendTo ( element.parent() ); 
		    }
		    else 
		        error.insertAfter(element); 
		} 

	});
	
});


</script>
</head>
<body>
		<s:form id="orgForm" action="/orgmain/addOrg.ct" method="post"  theme="simple"  >
			<table width="100%" class="tb" >
		        <tr class="tb-line">
		            <td class="tb-td" colspan="6">
			            <div class="tb-h2">POS收单运营管理平台</div>
				   	</td>
		        </tr>
               <tr class="tb-line bg-gray">
		            <td class="tb-td" colspan="4"><div class="tb-h3"><s:if test="#request.flag ==\"update\"">
		                	修改机构
		                	</s:if>
		                	<s:else>
		                	添加机构
		                	</s:else></div></td>
		        </tr>
				<tr class="tb-line">
			    	<td align="right" class="tb-td" style="width:110px;">
			        	<div class="tb-h4">所属区域：</div>
		            </td>
                   <td class="tb-td">
                   <!--修改  -->
                   <s:if test="#request.flag ==\"update\"">
			         <s:select name="orgmain.areaId" listKey="id" listValue="name"  cssClass="queryWidth"  list="areaCodeList" ></s:select>
                   <s:hidden name="orgmain.orgCode"></s:hidden>
                   </s:if>
                   <!--新增  -->
	               <s:else>
	               <s:select cssClass="queryWidth" name="orgmain.areaId" 
						list="areaCodeList" listKey="id" listValue="name" headerKey="" headerValue="---请选择---" /> 
	               </s:else>
	               <font color="red">*</font>
					</td>
					<td align="right" class="tb-td" style="width:110px;">
			        	<div class="tb-h4" id="title">机构名称：</div>
		            </td>
		            <td class="tb-td" >			             	
							<s:if test="#request.flag ==\"update\"">
							<label class="tb-input-lengthen">
							<s:textfield maxLength="100" theme="simple"   name="orgmain.orgName" cssClass="queryWidth"  value="%{orgmain.orgName}"></s:textfield>	
							</label>
							</s:if>
							<s:else>
							<label class="tb-input-lengthen">
		             		<s:textfield maxLength="100"  name="orgmain.orgName"
								cssClass="queryWidth"    ></s:textfield>
							</label>
							</s:else>
							<font color="red">*</font>
					</td>
				</tr>
				
				<tr class="tb-line">					
			    	<td align="right" class="tb-td" style="width:110px;">
			        		<div class="tb-h4">状态：</div>
		            </td>
		           <td class="tb-td" >   
						<s:if test="#request.flag ==\"update\"">
						<s:select name="orgmain.status" list="#{'2':'冻结','1':'正常'}" value="1"  cssClass="queryWidth"/>
						</s:if>
						<s:else>
						<s:select name="orgmain.status" list="#{'1':'正常','2':'冻结'}" value="1"  cssClass="queryWidth" />
						</s:else>
						<font color="red">*</font>
				   </td>
				</tr>	
			</table>		
	      <table width="100%" border="0" cellspacing="0" class="table">
	           	<tr class="tb-line">
					<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
						<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
								cssClass="fieldError" /></span>
						<span id="otherError"></span>
					</td>
				</tr>
				<tr class="tb-line">
		            <td class="tb-td line-submit" align="center" colspan="4">
		                <label class="tb-input-submit">		                
		                	<s:submit id="btnAdd" value="保  存" />								
						</label>
		                <label class="tb-input-submit">
							<input type="reset" value="取  消"/>
						</label>
						<label class="tb-input-submit">
							<input type="button" value="返回" onclick="history.back()"/>
						</label>
					</td>
				</tr>
            </table>
			</s:form>	
</body>
</html>
